home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / comm1 / s342q12.lha / syscfg.c < prev    next >
C/C++ Source or Header  |  1995-11-06  |  25KB  |  756 lines

  1. /************************************************************************/
  2. /*                              syscfg.c                                */
  3. /*      configuration program for Citadel bulletin board system.  This  */
  4. /* file contains the system dependent code!                             */
  5. /************************************************************************/
  6. #define SYSTEM_DEPENDENT
  7. #define CONFIGURE
  8. #include "ctdl.h"
  9. #include "c68door.h"
  10. #include "stdarg.h"
  11. #include "dos.h"
  12. #include "fcntl.h"
  13. /************************************************************************/
  14. /*                              History                                 */
  15. /*                                                                      */
  16. /* 89Oct17 HAW  Amiga.                                                  */
  17. /* 89Jan15 HAW  Major release update: colors, etc....                   */
  18. /* 87Jan19 HAW  Created.                                                */
  19. /************************************************************************/
  20. /************************************************************************/
  21. /*                              Contents                                */
  22. /*                                                                      */
  23. /* #    dirExists()             check to see if directory exists        */
  24. /* #    doCommon()              handles common stuff                    */
  25. /*      GetDoorData()           reads in some piece of the door data    */
  26. /*      initSysSpec()           initialization for system dependencies  */
  27. /*      NextNonWhite()          finds next piece of non-whitespace      */
  28. /*      NextWhite()             finds next piece of white space         */
  29. /*      StoreDoor()             manages the reading a door              */
  30. /*      SysDepIntegrity()       makes necessary checks for integrity    */
  31. /*      sysSpecs()              System-dependent code for configure     */
  32. /*                                                                      */
  33. /*              # means local for this implementation                   */
  34. /************************************************************************/
  35. /************************************************************************/
  36. /*              Statics                                                 */
  37. /************************************************************************/
  38.  
  39. char onConsole=TRUE, remoteSysop=TRUE; /* dummies */
  40.  
  41.  
  42. static int  necessary[MAX_NEEDED]   =
  43.   {
  44.   0, 0, 0, 0, 0, 0, 0, 0,   /* currently 16 fields */
  45.   0, 0, 0, 0, 0, 0, 0, 0,
  46.   };
  47. static char curDir[80];
  48. void *DoorName(DoorData *d, DoorData *s);
  49. static SListBase DoorList  =
  50.   {
  51.   NULL, DoorName, NULL, free, NULL
  52.  
  53.   };
  54. FILE *doorfl;
  55. void totalBytes(long *size, FILE *fd);
  56. /************************************************************************/
  57. /*                External variable declarations in CONFG.C             */
  58. /************************************************************************/
  59. /***** THESE ARE REQUIRED DEFINITIONS! ******/
  60. char *R_W_ANY     = "r+";
  61. char *W_R_ANY     = "w+";
  62. char *READ_ANY    = "r+";
  63. char *READ_TEXT   = "r";
  64. char *WRITE_ANY   = "w";
  65. char *WRITE_TEXT  = "w";
  66. /*****  done  *****/
  67. extern CONFIG cfg;       /* The configuration variable           */
  68. extern MessageBuffer   msgBuf;
  69. extern rTable *roomTab;
  70. void WrtDoor(DoorData *d);
  71. /************************************************************************/
  72. /*      dirExists() check to see if the directory exists                */
  73. /************************************************************************/
  74. void dirExists(char *theDir)
  75.   {
  76.   char cx;
  77.   extern char FirstInit, ReInit;
  78.   strCpy(msgBuf.mbtext, theDir);
  79.   /* if (strLen(theDir) == 0) return ; */
  80.   if (msgBuf.mbtext[strLen(msgBuf.mbtext)-1] == '/')
  81.   msgBuf.mbtext[strLen(msgBuf.mbtext)-1] = '\0';
  82.   #ifdef READY
  83.   if (doch(msgBuf.mbtext) == EOF)
  84.     {
  85.     sPrintf(msgBuf.mbtext, "%s is not a directory!", theDir);
  86.     illegal(msgBuf.mbtext);
  87.  
  88.     }
  89.   #else
  90.   if (chdir(msgBuf.mbtext) == 0)
  91.     {
  92.     chdir(curDir);
  93.     return;
  94.  
  95.     }
  96.   if (access(msgBuf.mbtext, 0) == 0)
  97.     {
  98.     sPrintf(msgBuf.mbtext, "%s is not a directory!", theDir);
  99.     illegal(msgBuf.mbtext);
  100.  
  101.     }
  102.   printf("\nThe directory '%s' doesn't exist.  Create it? ",
  103.   msgBuf.mbtext);
  104.   if (FirstInit)  printf("Y\n ");
  105.   cx = simpleGetch();
  106.   if (ReInit || FirstInit || toUpper(cx) == 'Y')
  107.   if (mkdir(msgBuf.mbtext) != 0)  illegal("Couldn't make directory!");
  108.   printf("Finished calling mkdir\n");
  109.   #endif
  110.   #ifdef READY
  111.   else
  112.     {
  113.     printf("\nThe directory '%s' doesn't exist.  Create it? ",
  114.     msgBuf.mbtext);
  115.     if (FirstInit)
  116.     printf("Y\n ");
  117.     if (ReInit || FirstInit || toUpper(simpleGetch()) == 'Y')
  118.     if (mkdir(msgBuf.mbtext) == BAD_DIR)
  119.     illegal("Couldn't make directory!");
  120.  
  121.     }
  122.   #endif
  123.   #ifdef READY
  124.   doch(curDir);
  125.   #endif
  126.  
  127.   }
  128. /************************************************************************/
  129. /*      sysSpecs()  system specific configure stuff                     */
  130. /************************************************************************/
  131. int sysSpecs(char *line, int offset, char *status, FILE *fd)
  132.   {
  133.   char var[90], string[90];
  134.   int  arg;
  135.   *status = TRUE;
  136.   if (sscanf(line, "%s %s ", var, string))
  137.     {
  138.     if (string[0] != '\"')
  139.       {
  140.       arg = atoi(string);
  141.  
  142.       }
  143.     if (strCmpU(var, "#HELPAREA"  )    == SAMESTRING)
  144.       {
  145.       doAreaCommon(var, line, &cfg.homeArea, HELP);
  146.       }
  147.     else if (strCmpU(var, "#QWKWORKAREA" ) == SAMESTRING)
  148.       {
  149.       doAreaCommon(var, line, &cfg.QwkWorkArea,QWK1);
  150.       }
  151.     else if (strCmpU(var, "#BIOAREA" ) == SAMESTRING)
  152.       {
  153.       doAreaCommon(var, line, &cfg.bioArea,BIO_AREA);
  154.       }
  155.     else if (strCmpU(var, "#QWKLOCATION" ) == SAMESTRING)
  156.       {
  157.       readString(line, &cfg.QwkLocation.saDirname[0], FALSE);
  158.       necessary[QWK1]++;
  159.       }
  160.     else if (strCmpU(var, "#QWKFILEAREA" ) == SAMESTRING)
  161.       {
  162.       doAreaCommon(var, line, &cfg.QwkFileArea,QWK2);
  163.       }
  164.     else if (strCmpU(var, "#QWKNAME" ) == SAMESTRING)
  165.       {
  166.       readString(line, (char *)&cfg.QwkName, FALSE);
  167.       necessary[QWK3]++;
  168.       }
  169.     else if (strCmpU(var, "#QWKMAXROOM" ) == SAMESTRING)
  170.       {
  171.       cfg.QwkMaxRooms = arg;
  172.       }
  173.     else if (strCmpU(var, "#QWKMAXPACKET" ) == SAMESTRING)
  174.       {
  175.       cfg.QwkMaxPacket = arg;
  176.       }
  177.     else if (strCmpU(var, "#door"  )    == SAMESTRING)
  178.       {
  179.       StoreDoor(line, fd);
  180.  
  181.       }
  182.     else if (strCmpU(var, "#LOGAREA"  )    == SAMESTRING)
  183.       {
  184.       doAreaCommon(var, line, &cfg.logArea, LOG);
  185.  
  186.       }
  187.     else if (strCmpU(var, "#ROOMAREA"  )    == SAMESTRING)
  188.       {
  189.       doAreaCommon(var, line, &cfg.roomArea, ROOM);
  190.  
  191.       }
  192.     else if (strCmpU(var, "#MSGAREA"  )    == SAMESTRING)
  193.       {
  194.       doAreaCommon(var, line, &cfg.msgArea, MSG);
  195.  
  196.       }
  197.     else if (strCmpU(var, "#MSG2AREA" )    == SAMESTRING)
  198.       {
  199.       doAreaCommon(var, line, &cfg.msg2Area, MSG2);
  200.  
  201.       }
  202.     else if (strCmpU(var, "#NETAREA"  )    == SAMESTRING)
  203.       {
  204.       doAreaCommon(var, line, &cfg.netArea, NET_STUFF);
  205.  
  206.       }
  207.     else if (strCmpU(var, "#DOMAINAREA"  )    == SAMESTRING)
  208.       {
  209.       doAreaCommon(var, line, &cfg.domainArea, DOMAIN_STUFF);
  210.  
  211.       }
  212.     else if (strCmpU(var, "#AUDITAREA"  )    == SAMESTRING)
  213.       {
  214.       doAreaCommon(var, line, &cfg.auditArea, CALL);
  215.       cfg.Audit = 1;
  216.  
  217.       }
  218.     else if (strCmpU(var, "#HOLDAREA"  )    == SAMESTRING)
  219.       {
  220.       doAreaCommon(var, line, &cfg.holdArea, HOLD);
  221.       cfg.BoolFlags.HoldOnLost = TRUE;
  222.  
  223.       }
  224.     else if (strCmpU(var, "#FLOORAREA" )    == SAMESTRING)
  225.       {
  226.       doAreaCommon(var, line, &cfg.floorArea, FLOORA);
  227.  
  228.       }
  229.     else if (strCmpU(var, "#NET_RECEPT_AREA")   == SAMESTRING)
  230.       {
  231.       anyArea(var, line, cfg.receptArea.naDirname);
  232.  
  233.       }
  234.     else if (strCmpU(var, "#EDITOR") == SAMESTRING)
  235.       {
  236.       cfg.BoolFlags.SysopEditor = TRUE;
  237.       readString(line, cfg.DepData.Editor, FALSE);
  238.  
  239.       }
  240.     else if (strCmpU(var, "#EDIT-AREA") == SAMESTRING)
  241.       {
  242.       readString(line, cfg.DepData.EditArea, FALSE);
  243.  
  244.       }
  245.     else if (strCmpU(var, "#REINIT") == SAMESTRING)
  246.       {
  247.       readString(line, cfg.DepData.HiSpeedInit, TRUE);
  248.       if (strLen(cfg.DepData.HiSpeedInit) >=
  249.       sizeof cfg.DepData.HiSpeedInit)
  250.       illegal("The #REINIT parameter is too long.  29 is the max.");
  251.  
  252.       }
  253.     else if (strCmpU(var, "#LOCK-PORT") == SAMESTRING)
  254.       {
  255.       if (arg < 0 || arg > 8)
  256.       illegal("Bad value for #LOCK-PORT: 0-8 valid only.");
  257.       cfg.DepData.LockPort = arg;
  258.  
  259.       }
  260.     else if (strCmpU(var, "#CLOCK"   ) == SAMESTRING)
  261.       {
  262.       cfg.DepData.Clock &= SER_7WIRE;  /* save serial  7 wire flag */
  263.       if (     strCmpU(string, "none"  ) == SAMESTRING)
  264.       cfg.DepData.Clock |= NO_CLOCK;
  265.       else if (strCmpU(string, "inuse" ) == SAMESTRING)
  266.       cfg.DepData.Clock |= BUSY_CLOCK;
  267.       else if (strCmpU(string, "always") == SAMESTRING)
  268.       cfg.DepData.Clock |= ALWAYS_CLOCK;
  269.       else illegal("Didn't understand #CLOCK value.");
  270.  
  271.       }
  272.     else if (strCmpU(var, "#modemSetup"   ) == SAMESTRING)
  273.       {
  274.       readString(line, cfg.DepData.ModemSetup, TRUE);
  275.       strCat(cfg.DepData.ModemSetup, "\r");
  276.  
  277.       }
  278.     else if (strCmpU(var, "#SCREENWIDTH") == SAMESTRING)
  279.       {
  280.       if (arg < 640 || arg > 740)
  281.       illegal("The #SCREENWIDTH parameter is not between 640 and 740.");
  282.       cfg.DepData.ScreenWidth = arg;
  283.  
  284.       }
  285.     else if (strCmpU(var, "#SCREENHEIGHT") == SAMESTRING)
  286.       {
  287.       if (arg < 100 || (arg > 300 && arg < 400) || arg > 500)
  288.       illegal("The #SCREENHEIGHT parameter is not valid.");
  289.       cfg.DepData.ScreenHeight = arg;
  290.  
  291.       }
  292.     else if (strCmpU(var, "#SCREENCOLOR0") == SAMESTRING)
  293.       {
  294.       cfg.DepData.Color0 = arg;
  295.  
  296.       }
  297.     else if (strCmpU(var, "#SCREENCOLOR1") == SAMESTRING)
  298.       {
  299.       cfg.DepData.Color1 = arg;
  300.  
  301.       }
  302.     else if (strCmpU(var, "#DISABLEECHO") == SAMESTRING)
  303.       {
  304.       cfg.DepData.StartUpEcho = FALSE;
  305.  
  306.       }
  307.     else if (strCmpU(var, "#DIRECTTOCHIP") == SAMESTRING)
  308.       {
  309.       cfg.DepData.DirectToChip = TRUE;
  310.  
  311.       }
  312.     else if (strCmpU(var, "#WBENCHWINDOW") == SAMESTRING)
  313.       {
  314.       cfg.DepData.ScreenDepth = TRUE;
  315.  
  316.       }
  317.     else if (strCmpU(var, "#SERIALDEVICE") == SAMESTRING)
  318.       {
  319.       readString(line, cfg.DepData.DevName, FALSE);
  320.  
  321.       }
  322.     else if (strCmpU(var, "#UNITNUMBER") == SAMESTRING)
  323.       {
  324.       cfg.DepData.UnitNumber = arg;
  325.  
  326.       }
  327.     else if (strCmpU(var, "#SERIAL_7WIRE") == SAMESTRING)
  328.       {
  329.       cfg.DepData.Clock |= SER_7WIRE;
  330.  
  331.       }
  332.     else *status = FALSE;
  333.  
  334.     }
  335.   return offset;
  336.  
  337.   }
  338. /************************************************************************/
  339. /*      doAreaCommon() handles common stuff                             */
  340. /************************************************************************/
  341. void doAreaCommon(char *var, char *line, SYS_AREA *area, int which)
  342.   {
  343.   char *c;
  344.   anyArea(var, line, area->saDirname);
  345.   /**
  346.     make sure the directory name has a trailing slash or colon
  347.   **/
  348.   c = area->saDirname;
  349.   c += strlen(c) - 1;  /* get pointer to last character */
  350.   if( *c != ':' && *c != '/' )
  351.     {
  352.     c[1] = '/';   /* add a trailing slash */
  353.     c[2] = '\0';
  354.     };
  355.   necessary[which]++;
  356.  
  357.   }
  358. /************************************************************************/
  359. /*      anyArea() handles common stuff                                  */
  360. /************************************************************************/
  361. void anyArea(char *var, char *line, char *target)
  362.   {
  363.   readString(line, target, FALSE);
  364.  
  365.   }
  366. /************************************************************************/
  367. /*      initSysSpec() initialization for system dependencies            */
  368. /************************************************************************/
  369. void initSysSpec()
  370.   {
  371.   getcwd(curDir, sizeof curDir);
  372.   cfg.DepData.Editor[0]      =      0;
  373.   cfg.DepData.EditArea[0]    =      0;
  374.   cfg.DepData.HiSpeedInit[0] =      0;
  375.   cfg.DepData.LockPort       =     -1;
  376.   cfg.DepData.Clock          = ALWAYS_CLOCK;
  377.   cfg.DepData.ScreenWidth    =    640;
  378.   cfg.DepData.ScreenHeight   =    200;
  379.   cfg.DepData.ScreenDepth    =      0; /*WBENCHWINDOW*/
  380.   cfg.DepData.Color0         = 0x0018;
  381.   cfg.DepData.Color1         = 0x0FFF;
  382.   cfg.DepData.StartUpEcho    =      1;
  383.   cfg.DepData.DirectToChip   =      0;
  384.   cfg.DepData.UnitNumber     =      0;
  385.   cfg.QwkMaxRooms            =     20;
  386.   cfg.QwkMaxPacket           =    200;
  387.   strcpy(cfg.DepData.DevName,"serial.device");
  388.  
  389.   }
  390. #define WhiteSpace(x)   ((x) == ' ' || (x) == '\t' || (x) == '\n')
  391. /*
  392. * #door <entrycode> <program name> <location> <who> <where> <how long>
  393. * <description>
  394. * <parameter list>
  395. */
  396. /************************************************************************/
  397. /*      StoreDoor() manages the reading and interpretation of a door    */
  398. /************************************************************************/
  399. void StoreDoor(char *line, FILE *fd)
  400.   {
  401.   char     *s;
  402.   DoorData *DoorInfo;
  403.   char     l2[100];
  404.   char     temp[15];
  405.   DoorInfo = (DoorData *) GetDynamic(sizeof *DoorInfo);
  406.   zero_struct(*DoorInfo);
  407.   line += 5;  /* now we point at the space before the entry code. */
  408.   /* get entrycode */
  409.   if ((line = GetDoorData(line, DoorInfo->entrycode, 6)) == NULL)
  410.     illegal("Problem with parsing the entry code for a door!");
  411.   /* get program name */
  412.   if ((line = GetDoorData(line, DoorInfo->program, 14)) == NULL)
  413.     illegal("Problem with parsing the program for a door!");
  414.   /* get door preferred location */
  415.   if ((line = GetDoorData(line, DoorInfo->location, 50)) == NULL)
  416.     illegal("Problem with parsing the location of a door! (d1)");
  417.   /* get door privilege */
  418.   if ((line = GetDoorData(line, temp, 15)) == NULL)
  419.     illegal("Problem with parsing the location of a door (d2)!");
  420.   if (strCmpU(temp, "anyone") == SAMESTRING)
  421.     DoorInfo->flags |= DOOR_ANYONE;
  422.   else if (strCmpU(temp, "aide") == SAMESTRING)
  423.     DoorInfo->flags |= DOOR_AIDE;
  424.   else if (strCmpU(temp, "sysop") == SAMESTRING)
  425.     DoorInfo->flags |= DOOR_SYSOP;
  426.   else if (strCmpU(temp, "autodoor") == SAMESTRING)
  427.     DoorInfo->flags |= DOOR_AUTO;
  428.   else if (strCmpU(temp, "newusers") == SAMESTRING)
  429.     DoorInfo->flags |= DOOR_NEWUSER;
  430.   else illegal("Could not identify who is allowed to use this door!");
  431.   /* get MODEM/CONSOLE/EITHER flag */
  432.   if ((line = GetDoorData(line, temp, 15)) == NULL)
  433.     illegal("Problem with parsing the 'where' field!");
  434.   if (strCmpU(temp, "anywhere") == SAMESTRING)
  435.     {
  436.     DoorInfo->flags |= DOOR_CON;
  437.     DoorInfo->flags |= DOOR_MODEM;
  438.  
  439.     }
  440.   else if (strCmpU(temp, "console") == SAMESTRING)
  441.   DoorInfo->flags |= DOOR_CON;
  442.   else if (strCmpU(temp, "modem") == SAMESTRING)
  443.   DoorInfo->flags |= DOOR_MODEM;
  444.   else illegal("Could not identify the 'where' value!");
  445.   /* get time limit of door */
  446.   if ((line = GetDoorData(line, temp, 15)) == NULL)
  447.   illegal("Problem with parsing the 'time' field!");
  448.   if (strCmpU(temp, "unlimited") == SAMESTRING)
  449.   DoorInfo->TimeLimit = -1;
  450.   else
  451.   DoorInfo->TimeLimit = atoi(temp);
  452.   /* Now get optional room to tie this door to */
  453.   if ((s = strrchr(line, '\n')) != NULL) *s = 0;
  454.   strCpy(DoorInfo->RoomName, line);
  455.   /* get description of door */
  456.   if (fgets(l2, 100, fd) == NULL) illegal("Unexpected EOF in door handling!");
  457.   if ((s = strrchr(l2, '\n')) != NULL) *s = 0;
  458.   if (strLen(l2) >= 80)  illegal("Description too long!");
  459.   strCpy(DoorInfo->description, l2);
  460.   /* get parameters of door */
  461.   if (fgets(l2, 100, fd) == NULL) illegal("Unexpected EOF in door handling!");
  462.   if ((s = strrchr(l2, '\n')) != NULL) *s = 0;
  463.   if (strLen(l2) >= 99) illegal("Parameters too long!");
  464.   strCpy(DoorInfo->parameters, l2);
  465.   AddData(&DoorList, DoorInfo, NULL, FALSE);
  466.  
  467.   }
  468. /************************************************************************/
  469. /*      GetDoorData() reads in some piece of the door data.             */
  470. /************************************************************************/
  471. char *GetDoorData(char *line, char *field, int size)
  472.   {
  473.   char *s;
  474.   if ((line = NextNonWhite(line)) == NULL)
  475.   return NULL;
  476.   /* Now skip over field so we may zero out & copy */
  477.   if ((s = NextWhite(line)) == NULL)
  478.   return NULL;
  479.   *s = 0;             /* zero whitespace */
  480.   if (strLen(line) >= size)
  481.     {
  482.     printf("Value '%s' too long for door's data field.\n", line);
  483.     return NULL;
  484.  
  485.     }
  486.   strCpy(field, line);
  487.   return s + 1;
  488.  
  489.   }
  490. /************************************************************************/
  491. /*      NextWhite() Finds next piece of white space on the line.        */
  492. /************************************************************************/
  493. char *NextWhite(char *line)
  494.   {
  495.   char *s;
  496.   for (s = line; !WhiteSpace(*s) && *s; s++)
  497.   ;
  498.   if (!(*s)) return NULL;
  499.   return s;
  500.  
  501.   }
  502. /************************************************************************/
  503. /*      NextNonWhite() Finds next piece of non-whitespace.              */
  504. /************************************************************************/
  505. char *NextNonWhite(char *line)
  506.   {
  507.   char *s;
  508.   for (s = line; WhiteSpace(*s) && *s; s++)
  509.   ;
  510.   if (!(*s)) return NULL;
  511.   return s;
  512.  
  513.   }
  514. FILE *upfd;
  515. /************************************************************************/
  516. /*      WriteDoors() writes out the list of doors.                      */
  517. /************************************************************************/
  518. void WriteDoors()
  519.   {
  520.   SYS_FILE DoorFile;
  521.   makeSysName(DoorFile, DOOR_DATA, &cfg.roomArea);
  522.   if ((doorfl = fopen(DoorFile, WRITE_ANY)) == NULL)
  523.     {
  524.     sPrintf(msgBuf.mbtext, "Could not create %s.", DoorFile);
  525.     illegal(msgBuf.mbtext);
  526.  
  527.     }
  528.   RunList(&DoorList, WrtDoor);
  529.  
  530.   }
  531. /************************************************************************/
  532. /*      WrtDoor() writes out a single door.                             */
  533. /************************************************************************/
  534. void WrtDoor(DoorData *d)
  535.   {
  536.   if( fwrite(d, sizeof *d, 1, doorfl) != 1 )
  537.     {
  538.     printf("Write error: Door data file\n");
  539.     };
  540.   }
  541. /************************************************************************/
  542. /*      SysDepIntegrity() makes necessary checks for integrity          */
  543. /************************************************************************/
  544. static char Check_Flag(int flag, int orflag, char *message);
  545. static char Check_Flag(int flag, int orflag, char *message)
  546.   {
  547.   if( !flag )
  548.     {
  549.     printf(" --%s parameters were not completely defined\n",message);
  550.     orflag = TRUE;
  551.     };
  552.   return ( char )orflag;
  553.   }
  554.  
  555. char SysDepIntegrity(int *offset)
  556.   {
  557.   char bad;
  558.   bad = Check_Flag(necessary[HELP],    FALSE, "Help");
  559.   bad = Check_Flag(necessary[MSG],       bad, "Message");
  560.   bad = Check_Flag(necessary[FLOORA],    bad, "Floor");
  561.   bad = Check_Flag(necessary[LOG],       bad, "User Log");
  562.   bad = Check_Flag(necessary[ROOM],      bad, "Room");
  563.   bad = Check_Flag(necessary[ BIO_AREA], bad, "Biography Area");
  564.  
  565.   if( necessary[QWK1] || necessary[QWK2] || necessary[QWK3] )
  566.     {
  567.     bad = Check_Flag(necessary[QWK1],   bad, "QWK Location");
  568.     bad = Check_Flag(necessary[QWK2],   bad, "QWK packet");
  569.     bad = Check_Flag(necessary[QWK3],   bad, "QWK file");
  570.     if( !bad )cfg.BoolFlags.QwkMail = 1;
  571.     }
  572.   if( cfg.Audit !=0 )bad = Check_Flag(necessary[CALL], bad, "Audit");
  573.   if( cfg.BoolFlags.mirror )
  574.     bad = Check_Flag(necessary[MSG2],   bad, "Mirror Message");
  575.   if( cfg.BoolFlags.netParticipant )
  576.     {
  577.     bad = Check_Flag(necessary[NET_STUFF],    bad, "Networking");
  578.     bad = Check_Flag(necessary[DOMAIN_STUFF], bad, "Domain");
  579.     };
  580.   if( bad )  illegal("See the above error messages.");
  581.   dirExists(cfg.homeArea.saDirname);
  582.   dirExists(cfg.logArea.saDirname);
  583.   dirExists(cfg.roomArea.saDirname);
  584.   dirExists(cfg.msgArea.saDirname);
  585.   dirExists(cfg.floorArea.saDirname);
  586.   dirExists(cfg.bioArea.saDirname);
  587.   if (cfg.BoolFlags.mirror)
  588.     dirExists(cfg.msg2Area.saDirname);
  589.   if (cfg.BoolFlags.netParticipant)
  590.     {
  591.     dirExists(cfg.netArea.saDirname);
  592.     dirExists(cfg.receptArea.naDirname);
  593.     dirExists(cfg.domainArea.saDirname);
  594.     };
  595.   if (cfg.Audit)
  596.     dirExists(cfg.auditArea.saDirname);
  597.   if (necessary[HOLD])
  598.     dirExists(cfg.holdArea.saDirname);
  599.   if( necessary[QWK1] || necessary[QWK3] )
  600.     {
  601.     dirExists(cfg.QwkWorkArea.saDirname);
  602.     dirExists(cfg.QwkFileArea.saDirname);
  603.     };
  604.   WriteDoors();
  605.   return TRUE;
  606.  
  607.   }
  608. int Dcount;
  609. /************************************************************************/
  610. /*      FindDoorSlot() looks for the specified door for autodoor stuff  */
  611. /************************************************************************/
  612. int FindDoorSlot(char *name)
  613.   {
  614.   int *c;
  615.   DoorData temp;
  616.   Dcount = 0;
  617.   strCpy(temp.entrycode, name);
  618.   if ((c = (int *) SearchList(&DoorList, &temp)) != NULL)
  619.   return *c;
  620.  
  621.   }
  622. /************************************************************************/
  623. /*      DoorName() check to see if this door is here.                                   */
  624. /************************************************************************/
  625. void *DoorName(DoorData *d, DoorData *s)
  626.   {
  627.   if (strCmpU(d->entrycode, s->entrycode) == SAMESTRING)
  628.   return &Dcount;
  629.   Dcount++;
  630.   return NULL;
  631.  
  632.   }
  633. /*************************************************************************/
  634. /*   simpleGetch() for AmigaDos version           */
  635. /*************************************************************************/
  636. int simpleGetch()
  637.   {
  638.   char inval;
  639.   do
  640.     {
  641.     scanf("%c",&inval);
  642.     inval = toupper(inval);
  643.  
  644.     }
  645.   while( (inval != 'Y') && (inval != 'N') );
  646.   return(inval);
  647.  
  648.   }
  649. /************************************************************************/
  650. /*              totalBytes() how many bytes in this here file?          */
  651. /************************************************************************/
  652. void totalBytes(long *size, FILE *fd)
  653.   {
  654.   *size = lseek(fileno(fd),-1l,2)+1;
  655.  
  656.   }
  657. char bigbuffer[7500];
  658. /************************************************************************/
  659. /*              mPrintf()  can you say kludge?                          */
  660. /************************************************************************/
  661. int mPrintf(char *format, ...)
  662.   {
  663.   va_list argptr;
  664.   va_start(argptr, format);
  665.   vsprintf(bigbuffer, format, argptr);
  666.   va_end(argptr);
  667.   printf("%s",bigbuffer);
  668.   return 0;
  669.   }
  670. /************************************************************************/
  671. /*      sPrintf() write from format+args to supplied string             */
  672. /************************************************************************/
  673. int sPrintf(char *garp, const char *format, ...)
  674.   {
  675.   va_list argptr;
  676.   va_start(argptr, format);
  677.   vsprintf(garp, format, argptr);
  678.   va_end(argptr);
  679.   return 0;
  680.   }
  681. char sysArgs(char *str)
  682.   {
  683.   return FALSE;
  684.  
  685.   }
  686. void *EatDirEntry(char *line);
  687. char DirDeleted = FALSE;
  688. SListBase DirRooms =
  689.   {
  690.   NULL, NULL, NULL, NULL, EatDirEntry
  691.  
  692.   };
  693. FILE *Dirs;
  694. /************************************************************************/
  695. /*      FinalSystemCheck() final system dependent checks                */
  696. /************************************************************************/
  697. int FinalSystemCheck(char OnlyParams)
  698.   {
  699.   SYS_FILE fn;
  700.   void WriteDir();
  701.   /* Check for excess entries in ctdldir.sys */
  702.   makeSysName(fn, "ctdldir.sys", &cfg.roomArea);
  703.   MakeList(&DirRooms, fn, NULL);
  704.   if (DirDeleted)
  705.     {
  706.     if ((Dirs = fopen(fn, WRITE_TEXT)) != NULL)
  707.       {
  708.       RunList(&DirRooms, WriteDir);
  709.       fclose(Dirs);
  710.  
  711.       }
  712.  
  713.     }
  714.   return TRUE;
  715.  
  716.   }
  717. void WriteDir(char *l)
  718.   {
  719.   fprintf(Dirs, "%s\n", l);
  720.  
  721.   }
  722. /************************************************************************/
  723. /*      EatDirEntry() validates an entry from ctdldir.sys               */
  724. /************************************************************************/
  725. void *EatDirEntry(char *line)
  726.   {
  727.   char *space;
  728.   int  room;
  729.   /* discard garbled entries */
  730.   if ((space = strchr(line, ' ')) == NULL)
  731.     {
  732.     DirDeleted = TRUE;
  733.     printf("Garbled entry -%s- deleted from ctdldir.sys.\n", line);
  734.     return NULL;
  735.  
  736.     }
  737.   room = atoi(line);
  738.   if (room >= MAXROOMS || room < 0)
  739.     {
  740.     DirDeleted = TRUE;
  741.     printf("Out of range entry -%s- deleted from ctdldir.sys.\n", line);
  742.     return NULL;
  743.  
  744.     }
  745.   if (roomTab[room].rtflags.INUSE && roomTab[room].rtflags.ISDIR)
  746.   return strdup(line);
  747.   DirDeleted = TRUE;
  748.   printf("Excess entry -%s- deleted from ctdldir.sys.\n", line);
  749.   return NULL;
  750.  
  751.   }
  752. /*  Stub routine for debug purposes */
  753. void splitF(FILE *fd, char *x,...)  { }
  754. void Do_Stack_Check(void);
  755. void Do_Stack_Check(void) { }
  756.